package com.buydeem.adapter;

/**
 * 适配器模式
 *
 * @author zengchao
 * @date 2022-04-29 11:50:50
 */
public class App {
    public static void main(String[] args) {
        //对象适配
        IOldLoginService oldLoginService = new OldLoginServiceImpl();
        INewLoginService newLoginService = new OldLoginAdapter(oldLoginService);
        newLoginService.loginWithUserNameAndPassword("mac","123456");

        //类适配
        newLoginService = new OldLoginAdapter2();
        newLoginService.loginWithUserNameAndPassword("jack","123456");

        //双向适配（新的适配旧的）
        IOldLoginService service = new TwoWayAdapter(new NewLoginServiceImpl());
        service.login("tom","654321");
    }
}
